﻿using Furion.TimeCrontab;

namespace ApiLib.Common.Attributes.TaskAttributes;

/// <summary>
/// 定时任务
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ScheduleAttribute : Attribute
{
    /// <summary>
    /// cron表达式
    /// </summary>
    public string Cron { get; set; } = "";
    /// <summary>
    /// cron表达式格式
    /// </summary>
    public CronStringFormat Format { get; set; } = CronStringFormat.Default;
    /// <summary>
    /// 是否采用并发执行
    /// </summary>
    public bool Concurrent { get; set; } = false;

    /// <summary>
    /// 毫秒周期
    /// </summary>
    public int Interval { get; set; } = 0;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="cron">cron表达式</param>
    public ScheduleAttribute(string cron)
    {
        Cron = cron;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="interval">毫秒周期</param>
    public ScheduleAttribute(int interval)
    {
        Interval = interval;
    }
}